﻿@model List<AddressModel>

@{
    Assets.AppendTitleParts(T("PageTitle.Account"));

    Layout = "_MyAccount";
    ViewBag.PageClassToken = "addresses";
    ViewBag.PageTitle = T("Account.CustomerAddresses").Value;
}

<div sm-if="Model.Count == 0" class="alert alert-warning">@T("Account.CustomerAddresses.NoAddresses")</div>

<div class="add-address">
    <a asp-action="AddressAdd" class="btn btn-primary btn-lg add-address-button mb-4" rel="nofollow">
        <i class="fa fa-plus"></i>
        <span>@T("Common.AddNew")</span>
    </a>
</div>

@if (Model.Count == 0)
{
    return;
}

<div class="card-deck card-cols-sm-1 card-cols-lg-2 address-list">
    @for (int i = 0; i < Model.Count; i++)
    {
        var address = Model[i];

        <div class="card shadow-sm address-list-item">
            <div class="card-body">
                <h4 class="card-title">@address.GetFormattedName()</h4>
                <div class="mb-2">
                    <div class="email">
                        <label asp-for="@Model[i].Email" class="m-0"></label>:
                        @address.Email
                    </div>
                    <div sm-if="address.PhoneEnabled" class="phone">
                        <label asp-for="@Model[i].PhoneNumber" class="m-0"></label>:
                        @address.PhoneNumber
                    </div>
                    <div sm-if="address.FaxEnabled && address.FaxNumber.HasValue()" class="fax">
                        <label asp-for="@Model[i].FaxNumber" class="m-0"></label>:
                        @address.FaxNumber
                    </div>
                </div>

                <div>
                    @Html.Raw(address.FormattedAddress)
                </div>
            </div>

            <div class="card-footer d-flex p-0">
                <a class="btn btn-secondary btn-lg btn-flat rounded-0 edit-address-button" asp-action="AddressEdit" asp-route-id="@address.Id">
                    <span>@T("Common.Edit")</span>
                </a>
                <a class="btn btn-danger btn-lg btn-flat rounded-0 delete-address-button" asp-action="AddressDelete" asp-route-id="@address.Id" onclick='return confirm(@T("Common.AreYouSure").JsValue);'>
                    <span>@T("Common.Delete")</span>
                </a>
            </div>
        </div>
    }
</div>